/*
 * Copyright (c) 2019-2029, <a href="https://wwww.intellijboy.cn">https://wwww.intellijboy.cn</a> (liuburu@qq.com).
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * <p>
 * <a href="https://www.apache.org/licenses/LICENSE-2.0">https://www.apache.org/licenses/LICENSE-2.0</a>
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package open.intellijboy.core.configuration.xingzhe;

import open.intellijboy.core.properties.IntellijProperties;
import open.intellijboy.core.exception.GlobalExceptionHandler;
import open.intellijboy.core.jackson.JackMappingMapperBuilderCustomizer;
import open.intellijboy.core.spring.listener.IntelliJApplicationListener;
import open.intellijboy.core.springboot.IntellijErrorAttributes;
import open.intellijboy.core.springboot.WebMvcPropertiesPostProcessor;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Intellijboy自动配置类
 *
 * @author intellijboy
 * @since 1.0
 */
@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties(IntellijProperties.class)
public class IntellijAutoConfiguration {

    /**
     * 日期标准格式化自定义
     *
     * @return 日期定制化bean
     */
    @Bean
    public JackMappingMapperBuilderCustomizer intellijMapperBuilderCustomizer() {
        return new JackMappingMapperBuilderCustomizer();
    }

    /**
     * 监听器
     *
     * @return 监听器bean
     */
    @Bean
    public IntelliJApplicationListener intelliJApplicationListener() {
        return new IntelliJApplicationListener();
    }

    /**
     * 后置处理器
     *
     * @return 后置处理器bean
     */
    @Bean
    public WebMvcPropertiesPostProcessor webMvcPropertiesPostProcessor() {
        return new WebMvcPropertiesPostProcessor();
    }

    /**
     * 自定义异常属性
     *
     * @return 自定义异常属性bean
     */
    @Bean
    public IntellijErrorAttributes intellijErrorAttributes() {
        return new IntellijErrorAttributes();
    }

    /**
     * 全局异常处理
     *
     * @return 全局异常处理bean
     */
    @Bean
    public GlobalExceptionHandler globalExceptionHandler() {
        return new GlobalExceptionHandler();
    }


}
